using System;

namespace lab03
{
    internal class HideMatrixDecorator : DrawableMatrix
    {
        private readonly DrawableMatrix _com;
        private int _hideColumn;
        private int _hideRow;
        private bool _isHide;

        public HideMatrixDecorator(DrawableMatrix com)
        {
            _com = com;
            _isHide = false;
        }

        public void HideOn()
        {
            _isHide = true;
            Random r = new Random();
            _hideColumn = r.Next(_com.GetNumColumns());
            _hideRow = r.Next(_com.GetNumRows());
        }

        public void HideOff()
        {
            _isHide = false;
        }


        public override void SetValue(int i, int j, int value)
        {
            _com.SetValue(i, j, value);
        }

        public override int GetValue(int i, int j)
        {
            return _com.GetValue(i, j);
        }

        public override int GetNumRows()
        {
            return _com.GetNumRows();
        }

        public override int GetNumColumns()
        {
            return _com.GetNumColumns();
        }

        public override void InternalDrawer(IMatrixDrawer drawer, DrawableMatrix matrix)
        {
            _com.InternalDrawer(drawer, matrix);
        }

        public override void DrawBorder(IMatrixDrawer drawer, int n, int m)
        {
            _com.DrawBorder(drawer, n, m);
        }

        public override void DrawCell(IMatrixDrawer drawer, int i, int j)
        {
            _com.DrawCell(drawer, i, j);
        }

        public override void DrawValue(IMatrixDrawer drawer, int i, int j, int value)
        {
            if (_isHide && (i == _hideColumn || j == _hideRow)) return;
            _com.DrawValue(drawer, i, j, value);
        }
    }


    internal class UpperMatrixDecorator : DrawableMatrix
    {
        private readonly DrawableMatrix _com;

        public UpperMatrixDecorator(DrawableMatrix com)
        {
            _com = com;

        }

        public override void SetValue(int i, int j, int value)
        {
            _com.SetValue(i, j, value);
        }

        public override int GetValue(int i, int j)
        {
            return _com.GetValue(i, j);
        }

        public override int GetNumRows()
        {
            return _com.GetNumRows();
        }

        public override int GetNumColumns()
        {
            return _com.GetNumColumns();
        }

        public override void InternalDrawer(IMatrixDrawer drawer, DrawableMatrix matrix)
        {
            _com.InternalDrawer(drawer, matrix);
        }

        public override void DrawBorder(IMatrixDrawer drawer, int n, int m)
        {
            _com.DrawBorder(drawer, n, m);
        }

        public override void DrawCell(IMatrixDrawer drawer, int i, int j)
        {
            _com.DrawCell(drawer, i, j);
        }

        public override void DrawValue(IMatrixDrawer drawer, int i, int j, int value)
        {
            if (i < j) return;
            _com.DrawValue(drawer, i, j, value);
        }

    }

}